import java.io.*;
public class computal
{
	
	public static void main(String args[])
	{
		
		data dat = new data();
		Lexer lex = new Lexer();
		Parser par = new Parser();
		CodeGenerator cgen = new CodeGenerator();
		dat.token= new StringBuffer("0");							//intializing token variable
		int error=0;
		
		if(args.length== 0)
		{
			System.out.println("Error-Filename expected as parameter in name ");
			System.exit(0);
		}	
		
		//initializing the inpu filename in data class
		dat.filename = args[0];
		
		error = par.parse(dat,lex);
		
		/*
		This is the call to the function for generating the
		cpp object code  of the program.
		 
		We are again making the line no and other variables zero
		for again starting the lexer function from the starting 
		of the file.
		*/
		if(error==1)
		System.exit(0);
		dat.line_no=0;
		dat.last=0L;
		dat.code=0;
		cgen.generator(dat,lex);
		
		/*
		Now we call the compilation of the cpp code of the 
		objec file by running a seprate process.
		*/
		String command= "g++ "+dat.filename+".cpp"; 
	        //Runtime rt = Runtime.getRuntime();     
	        Process child;
	        try{child = Runtime.getRuntime().exec(command);}catch(Exception e){}
 		/*
	        try{
	        	Process pr = rt.exec(command);
	        	
	        }catch(Exception e){}	*/	
	}	
}
